package v1

import (
	"github.com/gin-gonic/gin"
	"wrblog-api-go/app/api/v1/api_auth"
	"wrblog-api-go/app/api/v1/api_base"
	"wrblog-api-go/app/api/v1/api_sys"
	"wrblog-api-go/app/common/intercept"
	"wrblog-api-go/app/model/model_base"
	"wrblog-api-go/app/model/model_sys"
	"wrblog-api-go/pkg/request"
)

func WrSystemApi(apiV1 *gin.RouterGroup) {
	//获取列表
	apiV1.GET("/getLoginUser", api_auth.ApiLoginUser)
	apiV1.GET("/getUserInfo", api_auth.ApiUserInfo)
	apiV1.GET("/getRouters", api_sys.ApiRouters)
	sysUserApi := apiV1.Group("/sysUser")
	{
		sysUserApi.GET("/page", intercept.IsPermission("sys:user:list"), request.BindAllStruct[model_sys.SelectSysUser](), api_sys.ApiSysUserPageList)
		sysUserApi.GET("/:userId", intercept.IsPermission("sys:user:info"), api_sys.ApiSysUserById)
		sysUserApi.POST("/add", intercept.IsPermission("sys:user:add"), request.BindAllStruct[model_sys.SysUserPo](), api_sys.ApiAddSysUser)
		sysUserApi.PUT("/edit", intercept.IsPermission("sys:user:edit"), request.BindAllStruct[model_sys.SysUserPo](), api_sys.ApiEditSysUser)
		sysUserApi.DELETE("/removes", intercept.IsPermission("sys:user:remove"), api_sys.ApiRemoveSysUser)
	}
	sysMenuApi := apiV1.Group("/sysMenu")
	{
		sysMenuApi.GET("/getSelectTree", intercept.IsPermission("sys:menu:list"), api_sys.ApiSysMenuSelectTree)
		sysMenuApi.GET("/getTree", intercept.IsPermission("sys:menu:list"), request.BindAllStruct[model_sys.SelectSysMenu](), api_sys.ApiSysMenuTree)
		sysMenuApi.GET("/:menuId", intercept.IsPermission("sys:menu:info"), api_sys.ApiSysMenuById)
		sysMenuApi.POST("/add", intercept.IsPermission("sys:menu:add"), request.BindAllStruct[model_sys.SysMenuPo](), api_sys.ApiAddSysMenu)
		sysMenuApi.PUT("/edit", intercept.IsPermission("sys:menu:edit"), request.BindAllStruct[model_sys.SysMenuPo](), api_sys.ApiEditSysMenu)
		sysMenuApi.DELETE("/remove", intercept.IsPermission("sys:menu:remove"), api_sys.ApiRemoveSysMenu)
	}
	sysDictApi := apiV1.Group("/sysDict")
	{
		typeApi := sysDictApi.Group("/type")
		{
			typeApi.GET("/page", intercept.IsPermission("sys:dict:list"), request.BindAllStruct[model_sys.SelectSysDictType](), api_sys.ApiDictTypePageList)
			typeApi.GET("/:dictId", intercept.IsPermission("sys:dict:info"), api_sys.ApiDictTypeById)
			typeApi.POST("/add", intercept.IsPermission("sys:dict:add"), request.BindAllStruct[model_sys.SysDictTypePo](), api_sys.ApiAddDictType)
			typeApi.PUT("/edit", intercept.IsPermission("sys:dict:edit"), request.BindAllStruct[model_sys.SysDictTypePo](), api_sys.ApiEditDictType)
			typeApi.DELETE("/removes", intercept.IsPermission("sys:dict:remove"), api_sys.ApiRemoveDictType)
			typeApi.DELETE("/refreshCache", intercept.IsPermission("sys:dict:refresh"), api_sys.ApiRemoveCacheAll)
		}
		dataApi := sysDictApi.Group("/data")
		{
			dataApi.GET("/page", intercept.IsPermission("sys:dict:list"), request.BindAllStruct[model_sys.SelectSysDictData](), api_sys.ApiDictDataPageList)
			dataApi.GET("/list/:dictType", intercept.IsPermission("sys:dict:info"), api_sys.ApiDictDataByType)
			dataApi.GET("/:dictCode", intercept.IsPermission("sys:dict:list"), api_sys.ApiDictDataByCode)
			dataApi.POST("/add", intercept.IsPermission("sys:dict:add"), request.BindAllStruct[model_sys.SysDictDataPo](), api_sys.ApiAddDictData)
			dataApi.PUT("/edit", intercept.IsPermission("sys:dict:edit"), request.BindAllStruct[model_sys.SysDictDataPo](), api_sys.ApiEditDictData)
			dataApi.DELETE("/removes", intercept.IsPermission("sys:dict:remove"), api_sys.ApiRemoveDictData)
		}
	}
	sysRoleApi := apiV1.Group("/sysRole")
	{
		sysRoleApi.GET("/page", intercept.IsPermission("sys:role:list"), request.BindAllStruct[model_sys.SelectSysRole](), api_sys.ApiSysRolePageList)
		sysRoleApi.GET("/:roleId", intercept.IsPermission("sys:role:info"), api_sys.ApiSysRoleById)
		sysRoleApi.POST("/add", intercept.IsPermission("sys:role:add"), request.BindAllStruct[model_sys.SysRolePo](), api_sys.ApiAddSysRole)
		sysRoleApi.PUT("/edit", intercept.IsPermission("sys:role:edit"), request.BindAllStruct[model_sys.SysRolePo](), api_sys.ApiEditSysRole)
		sysRoleApi.DELETE("/removes", intercept.IsPermission("sys:role:remove"), api_sys.ApiRemoveSysRole)
	}
	sysPostApi := apiV1.Group("/sysPost")
	{
		sysPostApi.GET("/page", intercept.IsPermission("sys:post:list"), request.BindAllStruct[model_sys.SelectSysPost](), api_sys.ApiSysPostPageList)
		sysPostApi.GET("/:postId", intercept.IsPermission("sys:post:info"), api_sys.ApiSysPostById)
		sysPostApi.POST("/add", intercept.IsPermission("sys:post:add"), request.BindAllStruct[model_sys.SysPostPo](), api_sys.ApiAddSysPost)
		sysPostApi.PUT("/edit", intercept.IsPermission("sys:post:edit"), request.BindAllStruct[model_sys.SysPostPo](), api_sys.ApiEditSysPost)
		sysPostApi.DELETE("/removes", intercept.IsPermission("sys:post:remove"), api_sys.ApiRemoveSysPost)
	}
	sysConfigApi := apiV1.Group("/sysConfig")
	{
		sysConfigApi.GET("/refCache", intercept.IsPermission("sys:config:refresh"), api_sys.ApiCacheConfigList)
		sysConfigApi.GET("/page", intercept.IsPermission("sys:config:list"), request.BindAllStruct[model_sys.SelectSysConfig](), api_sys.ApiSysConfigPageList)
		sysConfigApi.GET("/:configId", intercept.IsPermission("sys:config:info"), api_sys.ApiSysConfigById)
		sysConfigApi.POST("/add", intercept.IsPermission("sys:config:add"), request.BindAllStruct[model_sys.SysConfigPo](), api_sys.ApiAddSysConfig)
		sysConfigApi.PUT("/edit", intercept.IsPermission("sys:config:edit"), request.BindAllStruct[model_sys.SysConfigPo](), api_sys.ApiEditSysConfig)
		sysConfigApi.DELETE("/removes", intercept.IsPermission("sys:config:remove"), api_sys.ApiRemoveSysConfig)
	}

	articleApi := apiV1.Group("/baseArticle")
	{
		articleApi.GET("/myPage", request.BindAllStruct[model_base.SelectBaseArticle](), api_base.ApiMyArticlePageList)
		articleApi.GET("/page", intercept.IsPermission("sys:article:list"), request.BindAllStruct[model_base.SelectBaseArticle](), api_base.ApiArticlePageList)
		articleApi.GET("/:articleId", intercept.IsPermission("sys:article:info"), api_base.ApiArticleInfo)
		articleApi.POST("/add", intercept.IsPermission("sys:article:add"), request.BindAllStruct[model_base.BaseArticlePo](), api_base.ApiAddArticle)
		articleApi.PUT("/edit", intercept.IsPermission("sys:article:edit"), request.BindAllStruct[model_base.BaseArticlePo](), api_base.ApiEditArticle)
		articleApi.DELETE("/removes", intercept.IsPermission("sys:article:remove"), api_base.ApiRemoveArticle)
	}
	articleGroupApi := apiV1.Group("/baseArticleGroup")
	{
		articleGroupApi.GET("/myPage", request.BindAllStruct[model_base.SelectBaseArticleGroup](), api_base.ApiMyArticleGroupPageList)
		articleGroupApi.GET("/page", intercept.IsPermission("sys:articleGroup:list"), request.BindAllStruct[model_base.SelectBaseArticleGroup](), api_base.ApiArticleGroupPageList)
		articleGroupApi.GET("/:groupId", intercept.IsPermission("sys:articleGroup:info"), api_base.ApiArticleGroupInfo)
		articleGroupApi.POST("/add", intercept.IsPermission("sys:articleGroup:add"), request.BindAllStruct[model_base.BaseArticleGroupPo](), api_base.ApiAddArticleGroup)
		articleGroupApi.PUT("/edit", intercept.IsPermission("sys:articleGroup:edit"), request.BindAllStruct[model_base.BaseArticleGroupPo](), api_base.ApiEditArticleGroup)
		articleGroupApi.DELETE("/removes", intercept.IsPermission("sys:articleGroup:remove"), api_base.ApiRemoveArticleGroup)
	}
	articleLabelApi := apiV1.Group("/baseArticleLabel")
	{
		articleLabelApi.GET("/myPage", request.BindAllStruct[model_base.SelectBaseArticleLabel](), api_base.ApiMyArticleLabelPageList)
		articleLabelApi.GET("/page", intercept.IsPermission("sys:articleLabel:list"), request.BindAllStruct[model_base.SelectBaseArticleLabel](), api_base.ApiArticleLabelPageList)
		articleLabelApi.GET("/:labelId", intercept.IsPermission("sys:articleLabel:info"), api_base.ApiArticleLabelInfo)
		articleLabelApi.POST("/add", intercept.IsPermission("sys:articleLabel:add"), request.BindAllStruct[model_base.BaseArticleLabelPo](), api_base.ApiAddArticleLabel)
		articleLabelApi.PUT("/edit", intercept.IsPermission("sys:articleLabel:edit"), request.BindAllStruct[model_base.BaseArticleLabelPo](), api_base.ApiEditArticleLabel)
		articleLabelApi.DELETE("/removes", intercept.IsPermission("sys:articleLabel:remove"), api_base.ApiRemoveArticleLabel)
	}
	articleLibraryApi := apiV1.Group("/baseArticleLibrary")
	{
		articleLibraryApi.GET("/myPage", request.BindAllStruct[model_base.SelectBaseArticleLibrary](), api_base.ApiMyArticleLibraryPageList)
		articleLibraryApi.GET("/page", intercept.IsPermission("sys:articleLibrary:list"), request.BindAllStruct[model_base.SelectBaseArticleLibrary](), api_base.ApiArticleLibraryPageList)
		articleLibraryApi.GET("/:libraryId", intercept.IsPermission("sys:articleLibrary:info"), api_base.ApiArticleLibraryInfo)
		articleLibraryApi.POST("/add", intercept.IsPermission("sys:articleLibrary:add"), request.BindAllStruct[model_base.BaseArticleLibraryPo](), api_base.ApiAddArticleLibrary)
		articleLibraryApi.PUT("/edit", intercept.IsPermission("sys:articleLibrary:edit"), request.BindAllStruct[model_base.BaseArticleLibraryPo](), api_base.ApiEditArticleLibrary)
		articleLibraryApi.DELETE("/removes", intercept.IsPermission("sys:articleLibrary:remove"), api_base.ApiRemoveArticleLibrary)
	}
}
